//搜索
$(".searchbooks").on('click',function () {
    var input=$(".search").val().trim();

    $("body").load("http://localhost:8080/searchbook?input="+input)

});
//返回
$(".returnput").on('click',function () {

    $("body").load("http://localhost:8080/put");

});
//下架
$(".maktablebtn").on('click',function () {
    var bookId=$(this).attr("data-id");
    $.ajax({
        type:"put",
        url: "http://localhost:8080/unmaktable",
        data: {"bookId":bookId},
        success:function (data) {
            if (data.status==1){
                alert(data.msg);
            }else {
                alert(data.msg);
            }
        },
        fail:function () {
            alert("服务器繁忙")
        },
        complete:function () {
        }
    })
});

//修改上架书籍信息
$(".editbooksbtn").on('click',function () {
    $(".editbooksplace").css('display','block');
    $(".puttable").css('display','none');
    var bookId=$(this).attr("data-id");
    var url="http://localhost:8080/putbooksInfrom?bookId="+bookId;
    $(".editbooksplace>iframe").attr("src",url);
});

$(".editOKFormbtn").on('click',function () {
    var bookName=$(".bookName1").val().trim();
    var bookNum=$(".bookNum1").val().trim();
    var author=$(".author1").val().trim();
    var brief=$(".brief1").val().trim();
    var bookId=$(this).attr("data-id");
    $.ajax({
        type:"post",
        url:"http://localhost:8080/editbooks",
        data:{"bookId":bookId,"bookName":bookName,"bookNum":bookNum,"author":author,"brief":brief},
        success:function (data) {
            if (data.status==1){
                alert(data.msg);
            }else {
                alert(data.msg);
            }
        },
        fail:function () {
            alert("服务器繁忙");
        },
        complete:function () {
        }
    })
});

//删除上架书籍
$(".delbooksbtn").on('click',function () {
   var bookId=$(this).attr("data-id");
   $.ajax({
       type:"post",
       url:"http://localhost:8080/delputbooks",
       data:{"bookId":bookId},
       success:function (data) {
           if (data.status==1){
               alert(data.msg);
           }else {
               alert(data.msg);
           }
       },
       fail:function () {
           alert("服务器繁忙");
       },
       complete:function () {
       }
   })
});